﻿CREATE TABLE [dbo].[Rider] (

	[Id] [dbo].[Id] NOT NULL  IDENTITY(1000000000, 1), 

    [Name] [dbo].[Name] NOT NULL, 

    [Description] [dbo].[Description] NOT NULL, 


	[InsuranceTypeId] [dbo].[Id] ,

	[UniqueId] [dbo].[BusinessId],

	[LegacyId] [dbo].[BusinessId] NULL,
    
	
	[Enabled] [dbo].[Enabled] NOT NULL DEFAULT 1,

    [CreateId] [dbo].[Name] NOT NULL DEFAULT SUSER_NAME () , 

    [CreateDateTime] [dbo].[CreateModifiedDateTime] NOT NULL DEFAULT GETDATE() , 

    [ModifiedId] [dbo].[Name] NOT NULL DEFAULT SUSER_NAME (),

    [ModifiedDateTime] [dbo].[CreateModifiedDateTime] NOT NULL DEFAULT GETDATE(), 
 
    CONSTRAINT [PK_Rider] PRIMARY KEY ([Id]), 

	CONSTRAINT [UNQ_Rider_Name] UNIQUE (Name),
	
	CONSTRAINT [UNQ_Rider_UniqueId] UNIQUE (UniqueId), 

    CONSTRAINT [FK_Rider_InsuranceTypeId] FOREIGN KEY (InsuranceTypeId) REFERENCES InsuranceType(Id)

)

GO

CREATE INDEX [IDX_Rider_UniqueId] ON [dbo].Rider (UniqueId)

GO

CREATE INDEX [IDX_Rider_LegacyId] ON [dbo].Rider (LegacyId)

GO